<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta name="renderer" content="webkit">
		<title>总管理登录</title>
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="icon" href="img/logo.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/clear.css" />
		<link rel="stylesheet" href="./css/official.css" />
		<style>
			
			input.form-control{
				border:none;
			}
			.aRow.clearfix{
				padding:10px 0;
				border-bottom:1px solid #eee;
				margin:0 -15px;
			}
			.card label{
				line-height:34px;
				margin-bottom:0;
				/*margin-left:-15px;*/
			}
			
			.detailsIMG{
				display: block;
				margin:50px auto 20px ;
				width:120px;
			}
			
			.detailsP{
				text-align:center;
				margin-bottom:30px;
			}
		</style>
	</head>

	<body style="background-color: #ccc;">
		<div class="official-hearder">
			<div class="official-hearder-top">
				<div class="official-content">
					<div class="clearfix">
						<div class="pull-right left-line-between" onclick="offcialExit()">
							退出
						</div>
						<div class="pull-right" id="walletName">
							--
						</div>
					</div>

				</div>
			</div>

			<div class="official-hearder-body clearfix">
				<div class="official-content">
					<div class="official-logo">
						<div style="width:30px;height:30px;background-color: #0C2D5A;"></div>
					</div>

					<div class="pull-right">
						<ul class="clearfix official-ul">
							<li class="active">
								<a href="javascript:;">API接口</a>
							</li>
							<li>
								<a href="officialProperty.html">资产信息</a>
							</li>
							<li>
								<a href="officialDeal.html">交易记录</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
			<div class="official-hearder-bottom clearfix">
				<div class="official-content">
					<h1>科学·社会</h1>
					<h3>名主富强和谐友善公正</h3>
				</div>
			</div>
		</div>
		<div class="official-body" style="margin-top:-30px;">
			<div class="official-content" style="background-color: #fff;padding:30px;">
				<div class="official-title">API接口</div>
				<div style="width:470px;margin:30px auto;">
					<div class="card" style="padding: 35px 60px;box-shadow: 1px 1px 10px #ccc;">
						<div id="cardBody"></div>
						<div style="padding:30px 60px;" >
							<button type="button" class="btn btn-block btn-primary" id="offcial-btn">提交</button>
						</div>
					</div>
				</div>

			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

		<script src="dist/js/adminlte.min.js"></script>
		<script type="text/javascript" src="js/argument.js"></script>
		<script type="text/javascript" src="js/getList.js"></script>
		<script type="text/javascript" src="js/fun.js"></script>
		<script type="text/javascript">
			
			function gameList(){
				var data = [];
				$.ajax({
					"type": 'post',
					"url": url + 'Home_GameList',
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("official_wallet_token")
					},
					async:false,
					success:function(res){
						if(res.status!=1){
							alert(res.error)
							return false;
						}
						console.log(res);
						$.each(res.data,function(index,item){
							data.push({name:item.name,id:item.id})
						})
					}
				})
				return data;
			}
			$("#walletName").text(localStorage.getItem("official_wallet_name"))
			
			function render(){
				$.ajax({
					"type": 'post',
					"url": url + 'Home_UserApiApplyStatus',
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("official_wallet_token")
					},
					success:function(res){
						if(res.status==1){
							$("#cardBody").html("");
							if(res.data.data_list==""){
								var str = '<div class="row"> <div class="aRow clearfix"> <div class="col-lg-3"> <label for="game_name">游戏名称</label> </div> <div class="col-lg-9"> <input type="text" class="form-control" id="game_name"></div> </div> <div class="aRow clearfix"> <div class="col-lg-3"> <label for="user_phone">联系人号码</label> </div> <div class="col-lg-9"> <input type="text" class="form-control" id="user_phone"/> </div> </div> <div class="aRow clearfix"> <div class="col-lg-3"> <label for="user_name">联系人名称</label> </div> <div class="col-lg-9"> <input type="text" class="form-control" id="user_name"/> </div> </div> <div class="aRow clearfix"> <div class="col-lg-12"> <label for="content">说明</label> </div> <div class="col-lg-12"> <textarea  class="form-control" id="content"></textarea> </div> </div> </div>'
								$("#cardBody").prepend(str)
								$("#offcial-btn").attr("status",0);
							}else if(res.data.data_list[0].status == 1){
								var list = gameList();
								var option ="";
								$.each(list,function(index,item){
									option += '<option value="'+item.id+'">'+ item.name +'</option>';
								})
								var str = '<div class="row"> <div class="aRow clearfix"> <div class="col-lg-3"> <label for="game_id">游戏</label> </div> <div class="col-lg-9"> <select type="text" class="form-control" id="game_id">'+option+'</select> </div> </div> <div class="aRow clearfix"> <div class="col-lg-3"> <label for="public_key">RSA公钥</label> </div> <div class="col-lg-9"> <input type="text" class="form-control" id="public_key"/> </div> </div> <div class="aRow clearfix"> <div class="col-lg-3"> <label for="back_url">回调URL</label> </div> <div class="col-lg-9"> <input type="text" class="form-control" id="back_url" placeholder ="URL需以 http:// 或  https:// 开头"/> </div> </div> <div class="aRow clearfix"> <div class="col-lg-12"> <label for="white_ips">IP白名单</label> </div> <div class="col-lg-12"> <textarea  class="form-control" id="white_ips" placeholder ="最多10个  用，隔开"></textarea> </div> </div> </div>';
								$("#cardBody").prepend(str)
								//$("#offcial-btn").hide("status",1);
								$("#offcial-btn").attr("status",1);
							}else{
								var text = '审核拒绝...';
								if(res.data.data_list[0].status==0){
									text = '审核中...';
								}else if(res.data.data_list[0].status==2){
									text = '审核拒绝...';
								}
								var str = '<div class="row"><img src="img/checked_'+res.data.data_list[0].status+'.png" class="detailsIMG"/></div><p class="detailsP">'+text+'</p>';//res.data.data_list[0].status
								$("#cardBody").prepend(str)
								$("#offcial-btn").remove();
							}
							
	//						$("#offcial-btn").attr("status",res.data.data_list[0].status)
						}else if(res.status==1000 || res.status==102 ){
							
						}else{
							alert(res.error)
							return false;
						}
					}
				})
			}
			
			render();
			//Home_UserApiApplyStatus
		</script>
		<script type="text/javascript">
			function UserApi(url,data){
				$.ajax({
					"type": 'post',
					"url": url + url,
					'contentType': "application/x-www-form-urlencoded",
					"headers": {
						"auth-token": localStorage.getItem("official_wallet_token")
					},
					data:{
						data:JSON.stringify(data),
					},
					async:false,
					success:function(res){
						if(res.status == 1){
							render();
						}else if(res.status == 1000||res.status == 102){
							alert("登录过期");
							window.location.href="officialLogin.html";
						}else{
							alert(res.error)
							return false;
						}
					}
				})
			}
			//public_key   //Home_UserApiSettingUpdate  //Home_UserApiApplyPost
			$("#offcial-btn").click(function(){
				if($(this).attr('status')==0){
					var data = {
						public_key:$("#public_key").val(),
						white_ips:$("#white_ips").val(),
						back_url:$("#back_url").val(),
						game_id:$("#game_id").val(),
					}
					UserApi('Home_UserApiSettingUpdate',data)
				}else if($(this).attr('status')==1){
					var data = {
						game_name:$("#game_name").val(),
						phone:$("#user_phone").val(),
						name:$("#user_name").val(),
						content:$("#content").val(),
					}
					UserApi('Home_UserApiApplyPost',data)
				}
			})
		</script>
	</body>
</html>